﻿@using Citi.GocAttributes.Domain
@model IEnumerable<Citi.GocAttributes.WebUI.Models.RuleConditionModel>
@if (Model == null || !Model.Any())
{
    <p>
        No Condition was assigned</p>
    return;
}
<table class="table table-bordered table-striped">
    <tr>
        <th>
            Type
        </th>
        <th>
            LegalVehicle
        </th>
        <th>
            Value
        </th>
    </tr>
    @foreach (var item in Model)
    {
        <tr class="@(Model.ToList().IndexOf(item) % 2 == 0 ? "odd" : "even")">
            <td>
                @item.Type.GetDescription()
            </td>
            <td>
                @if (item.Type == DatabaseEnums.RuleType.Function)
                {
                    @Html.DisplayFor(modelItem => item.Function.TreeLevel)
                }
                else if (item.Type == DatabaseEnums.RuleType.ManagedSegment)
                {
                    @Html.DisplayFor(modelItem => item.ManagedSegment.TreeLevel)
                }
            </td>
            <td>
                @switch (item.Type)
                {
                    case DatabaseEnums.RuleType.Function:
                        @(string.Concat(item.Function.Code, " - ", item.Function.Description))
                    break;
                    case DatabaseEnums.RuleType.ManagedSegment:
                        @(string.Concat(item.ManagedSegment.Code, " - ", item.ManagedSegment.Description))
                    break;
                    default:
                        @Html.DisplayFor(modelItem => item.Value)
                   break;
                }
                
            </td>
        </tr>
    }
</table>
